# -*- codeing = utf-8 -*-
# @Time : 2022/11/12 16:50
# @Author : 小马
# @File: Service.py
# @Software : PyCharm

#代价
import xlrd2


#将供水管网维修记录表中的信息插入到数据库中
def ReadAndAnalysisExcel():
    datelist=[]
    data = xlrd2.open_workbook("供水管网维修记录.xls")
    sheet = data.sheet_by_name("新交叉表_供水管网")
    for i in range(1,476):
        if(sheet.row(i)[7].value == "是"):
           date="2021-"+(sheet.row(i)[0].value)[4:6]+"-"+(sheet.row(i)[0].value)[6:8]
           datelist.append(date)
    return datelist

#其他、第三者/人为、非我司管辖范围 外腐蚀 自然老化 施工质量
def ReadAndAnalysisQuestion():
    result=[]
    a=0
    b=0
    c=0
    d=0
    e=0
    f=0
    datelist = []
    data = xlrd2.open_workbook("供水管网维修记录.xls")
    sheet = data.sheet_by_name("新交叉表_供水管网")
    for i in range(1,sheet.nrows):
        if(sheet.row(i)[3].value=="其他"):
            a=a+1
        elif(sheet.row(i)[3].value=="第三者/人为"):
            b=b+1
        elif (sheet.row(i)[3].value == "非我司管辖范围"):
            c = c + 1
        elif (sheet.row(i)[3].value == "外腐蚀"):
            d = d + 1
        elif (sheet.row(i)[3].value == "自然老化"):
            e = e + 1
        elif (sheet.row(i)[3].value == "施工质量"):
            f = f + 1
    result.append(a)
    result.append(b)
    result.append(c)
    result.append(d)
    result.append(e)
    result.append(f)
    return result


if __name__=='__main__':
    r=ReadAndAnalysisQuestion()
    print(r[1])





